home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-11
/
errorsys.zip
/
ERRORSYS.PRG
< prev
Wrap
Text File
|
1993-01-04
|
4KB
|
154 lines
*** ERRORSYS.PRG
*** Nantucket Corporation
*** Modifications made by Greg Lief 8/89 - 9/89
*** Modifications made by Kevin Harrison 9/30/89
*** This is basically the same as the ALTERROR.PRG provided by
*** Nantucket. Printer errors are recoverable, and if a "divide by
*** zero" is detected, a zero will be returned so as not to crash
*** your hard-working program. However, all other errors are (and
*** SHOULD be) considered non-recoverable. For such errors, I display
*** a pleasant box on the screen (as opposed to the terse one-line
*** message that usually appears at row 0). I also reprint the error
*** information, along with the current date and time, to the file
*** ERROR.TXT. This file is appended, so numerous error messages may
*** be written to disk. Hope it helps you out!
FUNCTION print_error
PARAM name, line
PRIVATE key, file
SET DEVICE TO SCREEN
@ 0, 0
@ 0, 0 SAY "Proc " + M->name + " line " + LTRIM(STR(M->line)) +;
", printer not ready"
@ 1, 0 SAY "Press <I>gnore, <R>etry, <B>REAK, F<ile>, <Q>uit..."
DO WHILE .T.
key = UPPER(CHR(INKEY(0)))
IF (M->key == "Q")
QUIT
ELSEIF (M->key == "I")
@ 0,0
@ 1,0
RETURN .F.
ELSEIF (M->key == "R")
@ 0,0
@ 1,0
RETURN .T.
ELSEIF (M->key == "B")
@ 0,0
@ 1,0
BREAK
ELSEIF (M->key == "F")
@ 0, 0
@ 1,0
ACCEPT "Filename - " TO file
SET PRINTER TO (M->file)
@ 0,0
@ 1,0
RETURN .T.
END
END
RETURN .F.
*** Expression Errors
*
function expr_error
parameters name, line, info, model, _1, _2, _3
** return 0 if zero divide error
IF M->info = "zero divide"
RETURN (IF("%" $ M->model, M->_1, 0))
ENDIF
goofed("Proc " +M->name +" line " +ltrim(str(M->line)) +", " +M->info)
return .f.
*** Undefined Symbol Errors
*
function undef_error
parameters name, line, info, model, _1
goofed("Proc " +M->name +" line " +ltrim(str(M->line)) + ", " +M->info +" " +M->_1)
return .f.
*** Miscellaneous Errors
*
function misc_error
parameters name, line, info, model
goofed("Proc " +M->name +" line " +ltrim(str(M->line)) +", " +M->info)
return .f.
*** File Open Errors
*
function open_error
parameters name, line, info, model, _1
* for network users this code is in clippers errorsys and is required to
*loop back to the users net_use() if trying to open an exclusively used file
*OPEN ERROR 5 on a use can than be handled as a normal file busy locked error
IF NETERR() .AND. model == "USE"
RETURN .F.
ENDIF
goofed("Proc " +M->name +" line " +ltrim(str(M->line)) + ;
", " +M->info +" " +M->_1 +" (" +ltrim(str(DOSERROR())) +")")
return .f.
*** Database Errors
*
function db_error
parameters name, line, info
private buffer, handle
goofed("Proc " +M->name +" line " +ltrim(str(M->line)) +", " +M->info)
return .f.
function goofed
param msg
set device to screen
set color to +w/r
@ 10, 8, 13, 72 BOX '┌─┐│┘─└│ '
@ 11, 10 SAY 'A system error has occurred - please consult your programmer'
TONE(880,1)
TONE(440,1)
TONE(220,1)
TONE(110,1)
do while .t.
if ! file('error.txt')
handle = fcreate('error.txt')
if ferror()=4 && if out of handles close databases,loop and retry
close databases
loop
endif
exit
else
handle = fopen('error.txt', 2)
if ferror()=4
close databases
loop
endif
fseek(handle, 0, 2) && move to end of file
exit
endif
enddo
buffer = 'System Error: ' + msg + CHR(13) + CHR(10) + ;
'Date: ' + DTOC(DATE()) + ' Time: ' + TIME() +' User: ' + netname() + CHR(13) + CHR(10) +;
REPLICATE('-',80) + CHR(13) + CHR(10)
fwrite(handle, buffer)
fclose(handle)
inkey(0)
set cursor on
set color to
clear
quit
return .f.
* EOF: ErrorSys.Prg